package com.louis.iread;

import android.app.Application;
import android.content.Context;

import com.baidu.autoupdatesdk.BDAutoUpdateSDK;
import com.baidu.autoupdatesdk.UICheckUpdateCallback;
import com.louis.iread.bean.Config;
import com.louis.iread.utils.SharedPreferencesUtil;
import com.louis.iread.skin.SkinMgr;
import com.orhanobut.logger.*;
import com.tencent.bugly.Bugly;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;

import org.xutils.x;


/**
 * Created by louis on 2016/11/12.
 */

public class IReadApplication extends Application {

    public static IReadApplication mInstance;

    public static boolean bIsTraditional = false;

    public static IReadApplication getInstance() {
        return mInstance;
    }
    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
        x.Ext.init(this);
        initPrefs();
        SkinMgr.getInstance().init(this);
        SkinMgr.getInstance().changeSkin(Config.getTheme());

        UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, null);
        MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);
        UMConfigure.setLogEnabled(true);

        BDAutoUpdateSDK.uiUpdateAction(this, new UICheckUpdateCallback() {
            @Override
            public void onNoUpdateFound() {

            }

            @Override
            public void onCheckComplete() {

            }
        });
        bIsTraditional = (this.getResources().getConfiguration().locale.getCountry().equals("TW") | this.getResources().getConfiguration().locale.getCountry().equals("HK"));
        Bugly.init(getApplicationContext(), "ac45764deb", false);
    }

    protected void initPrefs() {
        SharedPreferencesUtil.init(getApplicationContext(), getPackageName() + "_preference", Context.MODE_PRIVATE);
    }

    private void initLogger() {
        Logger.init().logLevel(LogLevel.FULL);
    }
}
